#ifndef		__HTTP_SOCKET_MGR__
#define		__HTTP_SOCKET_MGR__

#ifndef __Win32__
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/uio.h>
#include <unistd.h>
#include <netinet/tcp.h>
#include <fcntl.h>
#endif

#include "HashTable.h"
#include "BasicHashTable.h"
#include "ClientSession.h"

typedef struct _httpsession{
		UInt32		infd;
		UInt32		outfd;
		CClientSession *  pClient;
} CHTTPSession;

class HTTPSocketMgr
{
public:
	static HTTPSocketMgr * GetInstance();

	static void DelInstance();

	virtual ~HTTPSocketMgr(){
		while(true){
			if(m_httpsessionTable->IsEmpty()) break;
			CHTTPSession *pHttpSession = (CHTTPSession *)m_httpsessionTable->RemoveNext();			
			delete pHttpSession;
		}
		
		delete m_httpsessionTable;
	}

	void Initialize(){
		m_httpsessionTable = HashTable::create(STRING_HASH_KEYS);
	}

	void		PutInFD(int inFD, char * v_sessionID);
	void		PutOutFD(int outFD, char * v_sessionID);
	void		PutClientSession(CClientSession * pClient, char * v_sessionID);

	OS_Error	Get(int &outFD, CClientSession ** ppClient, char * v_sessionID);

	OS_Error	Remove(CClientSession * pClient);
	
private:
	HTTPSocketMgr(){}

private:


	static HTTPSocketMgr * mgr;

	HashTable *		m_httpsessionTable;

};

#endif



